package com.travel.group.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.travel.group.dao.ForumMapper;
import com.travel.group.entity.Forum;
import com.travel.group.service.ForumService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author Xudaoxu
 * @create 2021-05-26 2021/5/26
 */
@Service
public class ForumServiceImpl extends ServiceImpl<ForumMapper, Forum> implements ForumService {
    @Override
    public List<Forum> getByGroupIds(List<Integer> ids) {
        return baseMapper.selectBatchIds(ids);
    }

    @Override
    public List<Forum> getAllGroupInfo(Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        List<Forum> groups = baseMapper.selectList(null);
        return groups;
    }

    @Override
    public List<Forum> getAllGroupInfoPlus(Integer page, Integer limit, String name) {
        PageHelper.startPage(page, limit);
        List<Forum> groups = baseMapper.selectList(new QueryWrapper<Forum>().like("name",name));
        return groups;
    }

    @Override
    public List<Forum> getAllMyGroupInfo(Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        List<Forum> groups = baseMapper.selectList(null);
        return groups;
    }

    @Override
    public Integer countData() {
        List<Forum> groups = baseMapper.selectList(null);
        return groups.size();
    }
}
